import 'package:flutter/material.dart';
import 'package:wallpaper_app/components/SideBar/tabbar_nav.dart';
import 'package:wallpaper_app/pages/images/mohu/mohu_imgs.dart';

class MohuPage extends StatefulWidget {
  const MohuPage({super.key});

  @override
  State<MohuPage> createState() => _MohuPageState();
}

class _MohuPageState extends State<MohuPage> with TickerProviderStateMixin {
  List<String> subList = [
    '电脑壁纸',
    '类型一',
    '类型二',
    '高清风景壁纸',
    '喵星人',
    '缘之空',
    'SAO',
    '妖精的尾巴',
    '五等分的花嫁',
    '雷姆',
    '阿波连',
    '国家队02',
    '阿尼亚'
  ];
  late TabController tabController;
  int activeIndex = 0;
  PageController pageController = PageController(initialPage: 0);

  void getTypes() {}

  @override
  void initState() {
    getTypes();
    super.initState();
    tabController = TabController(length: subList.length, vsync: this);
    tabController.addListener(() {
      setState(() {
        activeIndex = tabController.index;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        TabbarNav(
          subList: subList,
          tabController: tabController,
          pageController: pageController,
        ),
        Expanded(
            child: PageView(
          controller: pageController,
          children: [
            MohuImgs(type: 'pc'),
            MohuImgs(type: 'img1'),
            MohuImgs(type: 'img2'),
            MohuImgs(type: 'gqbz'),
            MohuImgs(type: 'cat'),
            MohuImgs(type: 'yzk'),
            MohuImgs(type: 'sao'),
            MohuImgs(type: 'yaowei'),
            MohuImgs(type: '5huajia'),
            MohuImgs(type: 'rem'),
            MohuImgs(type: 'aharen'),
            MohuImgs(type: '02'),
            MohuImgs(type: 'aniya'),
          ],
          onPageChanged: (index) {
            setState(() {
              activeIndex = index;
            });
            tabController.animateTo(index);
          },
        ))
      ],
    );
  }
}
